cat /etc/profilecat /etc/bashrccat~/.bash_profilecat~/.bashrccat~/.bash_logoutset // As aboveecho$PATHhistoryenv
Users and Groups:
cat /etc/passwd cat /etc/group // List all groups on the systemcat /etc/shadow // Show user hashes – Privileged commandgrep -v -E"^#" /etc/passwd|awk -F: '$3 == 0 { print $1}' List all super user accountsfinger // Users currently logged inpinky // As aboveusers // As abovewho -a // As abovew // Who is currently logged in and what they’re doinglast // Listing of last logged on userslastlog // Information on when all users last logged inlastlog --user root // Information on when the specified user last logged in
User and Permission Information:
whoamiidcat /etc/sudoers // Who’s allowed to do what as root – Privileged commandsudo -l // Can the current user perform anything as rootcat /etc/passwd|cut -d: # List of usersgrep -v -E"^#" /etc/passwd|awk -F: '$3 == 0 { print $1}'# List of super usersawk -F: '($3 == "0") {print}' /etc/passwd # List of super userscat /etc/sudoers
What has the user being doing?
Is there any password in plain text? What have they been editing?
find /home –name .rhosts -print2>/dev/null ls -ahlR /root/ls -ahlR /home/ ls -la~/.*_history ls -la /usr/sbin/in.*find /var/log -type f -exec ls -la{};2>/dev/null
find /var/log -name*.log -type f -exec ls -la{};2>/dev/null
cat /etc/httpd/logs/access_logcat /etc/httpd/logs/access.logcat /etc/httpd/logs/error_logcat /etc/httpd/logs/error.logcat /var/run/utmpcat /var/webmin/miniserv.logcat /var/www/logs/access_logcat /var/www/logs/access.logls -alh /var/lib/dhcp3/find /etc/ -maxdepth 1 -name .conf -type f -exec ls -la{};2>/dev/null
ls -la /etc/*.conf As abovelsof -i -n ## List open files (output will depend on account privileges)lsof -u root ## lists all open files and processes by user root
find / -perm -u=s -type f 2>/dev/null #Find FILES that have the sticky bit set. find / -perm -1000 -type d 2>/dev/null # Find DIRECTORIES w/ Sticky bit - Only the owner of the directory or the owner of a file can delete or rename herefind / -perm -g=s -type f 2>/dev/null # SGID (chmod 2000) - run as the group, not the user who started it.find / -perm -u=s -type f 2>/dev/null # SUID (chmod 4000) - run as the owner, not the user who started it.find / -perm -g=s -o -perm -u=s -type f 2>/dev/null # SGID or SUIDfor i in `locate -r"bin$"`;dofind$i\( -perm -4000 -o -perm -2000\) -type f 2>/dev/null;done# Looks in 'common' places: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin and any other *bin, for SGID or SUID (Quicker search)find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld{}\;2>/dev/null
We found cp (copy) in the above list and now we are abusing it:
At the destination, the file owner will be root but the group will be that of the current user and
Notice the use of “–no-preserve” this is needed to read out protected files.
A lot of ways we can abuse this, update the shadow file with a new account, modify sudoers, plant ssh key + modify sshd_config ## + reboot,or cron.hourly.
/sbin/ifconfig -a // List all network interfacescat /etc/network/interfaces // As abovecat /etc/sysconfig/network arp -a Display ARP communicationsroute Display route informationcat /etc/resolv.conf Show configured DNS sever addressesnetstat -antp List all TCP sockets and related PIDs (-p Privileged command)
netstat -anup List all UDP sockets and related PIDs (-p Privileged command)
iptables -L List rules – Privileged commandcat /etc/services View port numbers/services mappings
What are the network configuration settings? What can you find out about this network? DHCP server? DNS server? Gateway?